package org.particlethink.response;

import org.particlethink.model.Acceptance;
import org.particlethink.model.Deliver;
import org.particlethink.model.Material;
import org.particlethink.model.PlanMaterial;

import java.text.SimpleDateFormat;

public class BillDownloadMaterialResponse {
    private String index;
    private String deliverNo;
    private String materialName;
    private String deliverAt;
    private String carNumber;
    private String unit;
    private String specification;
    private String expectNum;
    private String completeNum;
    private String deviation;
    private String deviationRate;

    public BillDownloadMaterialResponse(
            PlanMaterial planMaterial,
            Material material,
            Deliver deliver,
            Acceptance acceptance
    ) {
        this.deliverNo = deliver.getNo();
        this.materialName = material.getName();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
        this.deliverAt = deliver.getConfirmAt() == null ? "" : simpleDateFormat.format(deliver.getConfirmAt());
        this.carNumber = acceptance.getCarNumber();
        this.unit = material.getUnit();
        this.specification = material.getSpecification();
        this.expectNum = planMaterial.getExpectNum().toString();
        this.completeNum = planMaterial.getCompleteNum().toString();
        this.deviation = planMaterial.planDeviation(planMaterial.inventoryRate());
        this.deviationRate = planMaterial.inventoryRate().toString();
    }

    public BillDownloadMaterialResponse() {}

    public String getDeliverNo() {
        return deliverNo;
    }

    public void setDeliverNo(String deliverNo) {
        this.deliverNo = deliverNo;
    }

    public String getMaterialName() {
        return materialName;
    }

    public void setMaterialName(String materialName) {
        this.materialName = materialName;
    }

    public String getDeliverAt() {
        return deliverAt;
    }

    public void setDeliverAt(String deliverAt) {
        this.deliverAt = deliverAt;
    }

    public String getCarNumber() {
        return carNumber;
    }

    public void setCarNumber(String carNumber) {
        this.carNumber = carNumber;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getSpecification() {
        return specification;
    }

    public void setSpecification(String specification) {
        this.specification = specification;
    }

    public String getExpectNum() {
        return expectNum;
    }

    public void setExpectNum(String expectNum) {
        this.expectNum = expectNum;
    }

    public String getCompleteNum() {
        return completeNum;
    }

    public void setCompleteNum(String completeNum) {
        this.completeNum = completeNum;
    }

    public String getDeviation() {
        return deviation;
    }

    public void setDeviation(String deviation) {
        this.deviation = deviation;
    }

    public String getDeviationRate() {
        return deviationRate;
    }

    public void setDeviationRate(String deviationRate) {
        this.deviationRate = deviationRate;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }
}
